<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Validator;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    protected function validate($rules){
    	$validator = Validator::make(request()->input(), $rules);

    	if(count($this->getAttributes()) != 0){
			$validator->setAttributeNames($this->getAttributes());
    	}
		
        if ($validator->fails()) {
            throw new \Exception($validator->errors()->first(),10001);
        }
    }

    protected function getAttributes(){
        return [];
    }
}
